<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>10-事件循环-经典面试题</title>
  </head>
  <body>
    <h2>事件循环-经典面试题</h2>
    <script>
      console.log(1)

      setTimeout(() => {
        console.log(2)
        const p = new Promise(resolve => resolve(3))
        p.then(res => console.log(res))
      }, 0)

      const p = new Promise(resolve => {
        setTimeout(() => console.log(4), 0)
        resolve(5)
      })

      p.then(res => {
        console.log(res)
      })

      const p2 = new Promise(resolve => resolve(6))
      p2.then(res => console.log(res))
      console.log(7)

      // 姜：     1 7 2 5 6 3 4
      // 周思涵： 1 5 6 7 3 2 4
      // 周祺：   1 7 6 5 4 2 3
      // 乐：     1 7 5 6 2 3 4【对】
      //          1 7 4 5 6 2 3
      // 静：     1 7 5 6 4 2 3
      // 侯睿：   1 7 3 5 6 2 4
      // 付：     1 7 2 5 6 3 4
    </script>
  </body>
</html>
